package com.atguigu.juc.study.chapter05.interrupt;

import java.util.concurrent.TimeUnit;

/**
 * @author : leimingchao
 * @date Date : 2022年06月12日 17:28
 */
public class InterruptDemo4 {

    public static void main(String[] args) {

        Thread t1 = new Thread(() -> {

            for (int i = 0; i <= 300; i++) {
                System.out.println("-------:" + i);
            }
            System.out.println("t1线程调用interrupt()后的中断标识02：" + Thread.currentThread().isInterrupted());
        }, "t1");
        t1.start();

        System.out.println("t1线程默认的中断标识：" + t1.isInterrupted());

        try {
            TimeUnit.MILLISECONDS.sleep(2);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        t1.interrupt();

        System.out.println("t1线程调用interrupt()后的中断标识01：" + t1.isInterrupted());

        try {
            TimeUnit.MILLISECONDS.sleep(2000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }


        //false,中断不活动的线程不会产生任何影响
        System.out.println("t1线程调用interrupt()后的中断标识03：" + t1.isInterrupted());
    }
}
